<template>
  <div class="app-container">
    <!--*****************************************案卷级***********************************-->
    <el-divider content-position="left">案卷级</el-divider>
    <!--案卷信息数据-->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddArch">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdateArch"
          v-if="isAdmin"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDeleteArch"
          v-if="isAdmin"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImportArch">导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExportArch"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleApply"
          v-hasPermi="['system:archives:apply']"
        >归档申请</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleApprove"
          v-hasPermi="['system:archives:approve']"
        >归档通过</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleReject"
          v-hasPermi="['system:archives:reject']"
        >归档拒绝</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handlePrintBack"
          v-hasPermi="['system:archives:list']"
        >打印背脊</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-search"
          size="mini"
          @click="handleHeighArch"
        >高级查询</el-button>
      </el-col>
      <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getListArch"></right-toolbar> -->
    </el-row>
    <!------------------ 数据表格部分 ---------------->
    <el-table
      :data="archivesList"
      @selection-change="handleSelectionChangeArch"
      highlight-current-row
      @current-change="handleClickArch"
      border
      style="width: 100%"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- 可替换部分开始 -->
      <template v-for="(item, index) in tableHeaderViewArch">
        <el-table-column
          v-if="item.propType == 'datetime'"
          :formatter="dateFormat"
          :label="item.label"
          :prop="item.prop"
          align="center"
          :key="index"
          show-overflow-tooltip
        />
        <el-table-column
          v-else
          :label="item.label"
          :prop="item.prop"
          align="center"
          :key="index"
          show-overflow-tooltip
        />
      </template>
      <!-- 可替换部分结束 -->
      <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateTime" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实体借阅状态" align="center" prop="borwStatus" fixed="right">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.borwStatus === '0'">未借出</el-tag>
          <el-tag type="danger" v-if="scope.row.borwStatus === '1'">已借出</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="archStatus" fixed="right">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.archStatus == 0">未申请</el-tag>
          <el-tag v-if="scope.row.archStatus == 1">申请中</el-tag>
          <el-tag type="success" v-if="scope.row.archStatus == 2">已归档</el-tag>
          <el-tag type="danger" v-if="scope.row.archStatus == 3">审核拒绝</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120px"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateArch(scope.row)"
            v-if="scope.row.archStatus !== '2'"
          >修改</el-button>
          <el-dropdown
            size="mini"
            @command="(command) => handleCommandArch(command, scope.row)"
          >
            <span class="el-dropdown-link">
              <i class="el-icon-d-arrow-right el-icon--right"></i>更多
            </span>
            <el-dropdown-menu slot="dropdown">
              <!-- <el-dropdown-item command="handlePrintCover" icon="el-icon-circle-check">打印封皮</el-dropdown-item>
              <el-dropdown-item command="handlePrintBkTable" icon="el-icon-circle-check">打印备考表</el-dropdown-item>
              <el-dropdown-item command="handlePrintAcceptance" icon="el-icon-circle-check">打印验收清单</el-dropdown-item>-->
              <el-dropdown-item command="anjuanbaoExport" icon="el-icon-circle-check">案卷包导出</el-dropdown-item>
              <el-dropdown-item
                command="handleDeleteArch"
                icon="el-icon-delete"
                v-if="scope.row.archStatus !== '2'"
              >删除</el-dropdown-item>
              <el-dropdown-item
                command="handleMultipleFile"
                icon="el-icon-circle-check"
                v-if="scope.row.archStatus !== '2'"
                v-hasPermi="['system:archives:upload']"
              >批量上传</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      v-show="totalArch > 0"
      @size-change="handleSizeChangeArch"
      @current-change="handleCurrentChangeArch"
      :current-page.sync="pageNumArch"
      :page-sizes="page_size"
      :page-size.sync="pageSizeArch"
      layout="->, total, sizes, prev, pager, next, jumper"
      :total="totalArch"
    ></el-pagination>

    <!-- 添加或修改案卷管理对话框 -->
    <el-dialog :title="titleArch" :visible.sync="archOpen" width="80%" append-to-body>
      <el-form ref="formArch" :model="formArch" :rules="rulesArch" label-width="80px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="全宗号" prop="acFullAnces">
              <el-input v-model="formArch.acFullAnces" placeholder="请输入全宗号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="目录号" prop="acDirNum">
              <el-input v-model="formArch.acDirNum" placeholder="请输入目录号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="案卷号" prop="acArchNum">
              <el-input v-model="formArch.acArchNum" placeholder="请输入案卷号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="年度" prop="acYear">
              <el-input v-model="formArch.acYear" placeholder="请输入年度" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="分类号" prop="acCategoryNo">
              <el-input v-model="formArch.acCategoryNo" placeholder="请输入分类号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="密级" prop="acSecretLevel">
              <el-select v-model="formArch.acSecretLevel" filterable clearable placeholder="请选择">
                <el-option
                  v-for="item in dict.type.secret_level"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="案卷题名" prop="acFileTitle">
              <el-input v-model.trim="formArch.acFileTitle" placeholder="请输入案卷题名" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="保存期限" prop="acStoreTime">
              <el-select v-model="formArch.acStoreTime" placeholder="请选择">
                <el-option
                  v-for="item in dict.type.store_time"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="案卷ID" prop="id">
              <el-input v-model="formArch.id" readonly placeholder="不允许输入、修改" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6" v-if="is_docNum == 1">
            <el-form-item label="档号" prop="acDocNum">
              <el-input v-model="formArch.acDocNum" placeholder="请输入档号" />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 可替换部分开始 -->
        <el-row v-if="i%4==0" v-for="(item, i) in tableHeaderArch" :key="i">
          <el-col :span="6" v-for="(item, i) in propGroup(tableHeaderArch,i)" :key="i">
            <el-form-item :label="item.label" :prop="item.prop">
              <el-date-picker
                v-if="item.propType == 'date'"
                v-model="formArch[item.prop]"
                :placeholder="`请输入` + item.label"
                type="date"
                value-format="yyyy-MM-dd"
                style="width:165px"
                placeholder="选择日期"
              ></el-date-picker>
              <el-date-picker
                v-else-if="item.propType == 'datetime'"
                v-model="formArch[item.prop]"
                :placeholder="`请输入` + item.label"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width:165px"
                placeholder="选择时间"
              ></el-date-picker>
              <el-input
                v-else-if="item.propType == 'longtext'"
                v-model="formArch[item.prop]"
                :placeholder="`请输入` + item.label"
                type="textarea"
              />
              <el-input v-else v-model="formArch[item.prop]" :placeholder="`请输入` + item.label" />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 可替换部分结束 -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormArch">确 定</el-button>
        <el-button @click="cancelArch">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 案卷导入对话框 -->
    <el-dialog
      :title="uploadArch.title"
      :visible.sync="uploadArch.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="uploadArch"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="uploadArch.headers"
        :action="uploadArch.url"
        :disabled="uploadArch.isUploading"
        :on-progress="handleFileUploadProgressArch"
        :on-success="handleFileSuccessArch"
        :auto-upload="false"
        :data="uploadArch.data"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip text-center" slot="tip">
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplateArch"
          >下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileFormArch">确 定</el-button>
        <el-button @click="uploadArch.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 案卷高级查询对话框 -->
    <el-dialog
      :title="heightArch.title"
      :visible.sync="heightArch.open"
      width="560px"
      append-to-body
    >
      <el-row type="flex" justify="space-between">
        <el-col :span="10">
          <el-select v-model="heightParam" filterable clearable placeholder="请选择字段">
            <el-option
              v-for="item in tableHeaderViewArch"
              :key="item.value"
              :label="item.label"
              :value="item.prop"
            ></el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <div style="padding-left: 5px; padding-top: 7px">包含</div>
        </el-col>
        <el-col :span="10">
          <el-input v-model="heightValue" placeholder="请输入查询内容" />
        </el-col>
      </el-row>
      <el-row style="margin-top: 25px">
        <el-col :span="24">
          <el-form
            :model="queryParamsArch"
            ref="queryFormArch"
            :inline="true"
            v-show="showSearch"
            label-width="68px"
          >
            <el-form-item label="归档状态">
              <el-select
                v-model="queryParamsArch.archStatus"
                filterable
                clearable
                placeholder="请选择归档状态"
              >
                <el-option
                  v-for="item in heightOptionFinish"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="getHeightArch">搜 索</el-button>
        <el-button @click="heightArch.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!--*****************************************文件级***********************************-->
    <el-divider content-position="left">文件级</el-divider>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddFile">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdateFile"
          v-if="isAdmin"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleDeleteFile"
          v-if="isAdmin"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImportFile">导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-edit" size="mini" @click="handleExportFile">导出</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handlePrintMenu"
          v-hasPermi="['system:archives:list']"
        >打印</el-button>
      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-search"
          size="mini"
          @click="handleHeighFile"
        >高级查询</el-button>
      </el-col>
    </el-row>
    <!------------------ 数据表格部分 ---------------->
    <el-table
      :data="fileList"
      @selection-change="handleSelectionChangeFile"
      border
      style="width: 100%"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- 可替换部分开始 -->
      <template v-for="(item, index) in tableHeaderViewFile">
        <el-table-column
          v-if="item.propType == 'datetime'"
          :formatter="dateFormat"
          :label="item.label"
          :prop="item.prop"
          align="center"
          :key="index"
          show-overflow-tooltip
        />
        <el-table-column
          v-else
          :label="item.label"
          :prop="item.prop"
          align="center"
          :key="index"
          show-overflow-tooltip
        />
      </template>
      <!-- 可替换部分结束 -->
      <el-table-column
        label="文件"
        align="center"
        prop="filePath"
        min-width="300px"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.filePath == null || scope.row.filePath === ''">无文件</el-tag>
          <div v-if="scope.row.filePath != null && scope.row.filePath !== ''">
            <li
              :key="path"
              class="el-upload-list__item ele-upload-list__item-content"
              v-for="path in getFilePath(scope.row.filePath)"
            >
              <el-link :href="path" :underline="false" target="_blank">
                <span class="el-icon-document">
                  {{
                  getFileName(path)
                  }}
                </span>
              </el-link>
            </li>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="图片" align="center" prop="imagePath" width="100">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.imagePath == null || scope.row.imagePath === ''">无图片</el-tag>
          <image-preview
            v-if="scope.row.imagePath != null && scope.row.imagePath !== ''"
            :src="scope.row.imagePath"
            :width="50"
            :height="50"
          />
          <el-tag
            v-if="scope.row.imagePath != null  && scope.row.imagePath !== ''"
            type="success"
            class="point"
            @click="printImage(scope.row.imagePath)"
          >打印</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新时间" align="center" prop="updateTime" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="实体借阅状态" align="center" prop="borwStatus" fixed="right">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.borwStatus === '0'">未借出</el-tag>
          <el-tag type="danger" v-if="scope.row.borwStatus === '1'">已借出</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="归档状态" align="center" prop="archStatus" fixed="right">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.archStatus == 0">未申请</el-tag>
          <el-tag v-if="scope.row.archStatus == 1">申请中</el-tag>
          <el-tag type="success" v-if="scope.row.archStatus == 2">已归档</el-tag>
          <el-tag type="danger" v-if="scope.row.archStatus == 3">审核拒绝</el-tag>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120px"
        fixed="right"
        v-if="archStatus !== '2'"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdateFile(scope.row)"
          >修改</el-button>
          <el-dropdown size="mini" @command="(command) => handleCommandFile(command, scope.row)">
            <span class="el-dropdown-link">
              <i class="el-icon-d-arrow-right el-icon--right"></i>更多
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="handleDeleteFile" icon="el-icon-delete">删除</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      v-show="totalFile > 0"
      @size-change="handleSizeChangeFile"
      @current-change="handleCurrentChangeFile"
      :current-page.sync="pageNumFile"
      :page-sizes="page_size"
      :page-size.sync="pageSizeFile"
      layout="->, total, sizes, prev, pager, next, jumper"
      :total="totalFile"
    ></el-pagination>

    <!-- 添加或修改文件管理对话框 -->
    <el-dialog :title="titleFile" :visible.sync="openFile" width="80%" append-to-body>
      <el-form ref="formFile" :model="formFile" :rules="rulesFile" label-width="80px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="案卷题名" prop="archId">
              <el-select
                v-model="formFile.archId"
                filterable
                remote
                :remote-method="remoteMethodArch"
                automatic-dropdown
                clearable
                loading-text="加载中..."
                placeholder="请输入关键词"
              >
                <el-option
                  v-for="item in archivesListOption"
                  :key="item.id"
                  :label="item.acFileTitle"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="全宗号" prop="fullAnces">
              <el-input v-model="formFile.fullAnces" placeholder="请输入全宗号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="目录号" prop="dirNum">
              <el-input v-model="formFile.dirNum" placeholder="请输入目录号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="案卷号" prop="archNum">
              <el-input v-model="formFile.archNum" placeholder="请输入案卷号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="年度" prop="year">
              <el-input v-model="formFile.year" placeholder="请输入年度" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="分类号" prop="categoryNo">
              <el-input v-model="formFile.categoryNo" placeholder="请输入分类号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="密级" prop="secretLevel">
              <el-select v-model="formFile.secretLevel" filterable clearable placeholder="请选择">
                <el-option
                  v-for="item in dict.type.secret_level"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="保存期限" prop="storeTime">
              <el-select v-model="formFile.storeTime" placeholder="请选择">
                <el-option
                  v-for="item in dict.type.store_time"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="顺序号" prop="sequeNum">
              <el-input v-model="formFile.sequeNum" placeholder="请输入顺序号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="文件题名" prop="fileTitle">
              <el-input v-model.trim="formFile.fileTitle" placeholder="请输入文件题名" />
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="is_docNum == 1">
            <el-form-item label="档号" prop="docNum">
              <el-input v-model="formFile.docNum" placeholder="请输入档号" />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 可替换部分开始 -->
        <el-row v-if="i%4==0" v-for="(item, i) in tableHeaderFile" :key="i">
          <el-col :span="6" v-for="(item, i) in propGroup(tableHeaderFile,i)" :key="i">
            <el-form-item :label="item.label" :prop="item.prop">
              <el-date-picker
                v-if="item.propType == 'date'"
                v-model="formFile[item.prop]"
                :placeholder="`请输入` + item.label"
                type="date"
                value-format="yyyy-MM-dd"
                style="width:165px"
                placeholder="选择日期"
              ></el-date-picker>
              <el-date-picker
                v-else-if="item.propType == 'datetime'"
                v-model="formFile[item.prop]"
                :placeholder="`请输入` + item.label"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                style="width:165px"
                placeholder="选择时间"
              ></el-date-picker>
              <el-input
                v-else-if="item.propType == 'longtext'"
                v-model="formFile[item.prop]"
                :placeholder="`请输入` + item.label"
                type="textarea"
              />
              <el-input v-else v-model="formFile[item.prop]" :placeholder="`请输入` + item.label" />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 可替换部分结束 -->
        <el-form-item label="挂载序号" prop="mountNum">
          <el-input v-model="formFile.mountNum" placeholder="请输入挂载序号" />
        </el-form-item>
        <el-form-item label="图片上传" prop="imagePath">
          <file-upload v-model="formFile.imagePath" :fileType="imgType" :data="fileNum" />
        </el-form-item>
        <el-form-item label="文件上传" prop="filePath">
          <file-upload v-model="formFile.filePath" :data="fileNum" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormFile">确 定</el-button>
        <el-button @click="cancelFile">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 文件导入对话框 -->
    <el-dialog
      :title="uploadFile.title"
      :visible.sync="uploadFile.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="uploadFile"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="uploadFile.headers"
        :action="uploadFile.url"
        :disabled="uploadFile.isUploading"
        :on-progress="handleFileUploadProgressFile"
        :on-success="handleFileSuccessFile"
        :auto-upload="false"
        :data="uploadFile.data"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip text-center" slot="tip">
          <span>仅允许导入xls、xlsx格式文件。</span>
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplateFile"
          >下载模板</el-link>
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileFormFile">确 定</el-button>
        <el-button @click="uploadFile.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 批量文件上传 -->
    <el-dialog :title="titleFile" :visible.sync="openMult" width="80%" append-to-body>
      <el-form label-width="80px">
        <el-form-item label="文件上传">
          <file-upload v-model="filePath" :data="fileNumMult" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormFileMult">确 定</el-button>
        <el-button @click="cancelFile">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 文件高级查询对话框 -->
    <el-dialog
      :title="heightFile.title"
      :visible.sync="heightFile.open"
      width="560px"
      append-to-body
    >
      <el-row type="flex" justify="space-between">
        <el-col :span="10">
          <el-select v-model="heightParam" filterable clearable placeholder="请选择字段">
            <el-option
              v-for="item in tableHeaderViewFile"
              :key="item.value"
              :label="item.label"
              :value="item.prop"
            ></el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <div style="padding-left: 5px; padding-top: 7px">包含</div>
        </el-col>
        <el-col :span="10">
          <el-input v-model="heightValue" placeholder="请输入查询内容" />
        </el-col>
      </el-row>
      <el-row style="margin-top: 25px">
        <el-col :span="24">
          <el-form
            :model="queryParamsFile"
            ref="queryFormFile"
            :inline="true"
            v-show="showSearch"
            label-width="68px"
          ></el-form>
        </el-col>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="getHeightFile">搜 索</el-button>
        <el-button @click="heightFile.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getInfo } from "@/api/login";
import { treeselect, getType } from "@/api/system/type";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { getToken } from "@/utils/auth";
import print from "print-js";
import { listProp } from "@/api/tool/prop";
import { getDept } from "@/api/system/dept";

import {
  listFileA,
  getFileA,
  addFileA,
  updateFileA,
  delFileA,
  updateApply,
  updateApprove,
  updateReject,
  multFile
} from "@/api/system/archFileA";

export default {
  // 字典
  dicts: ["secret_level", "store_time"],
  // 组件传参
  props: {
    // 表对象集合
    subData: {
      type: Object,
      default: null
    }
  },
  components: { Treeselect },
  data() {
    // 案卷、文件id验证
    // var validId = (rule, value, callback) => {
    //     let reg = /^[1-9][0-9]*$/;
    //     if(!reg.test(value)){
    //       callback(new Error('只允许输入0~9阿拉伯数字'));
    //     } else {
    //       callback();
    //     }
    // };
    return {
      imgType: ["png", "jpg", "jpeg"],
      uploadImgUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
      // 项目根路径
      baseUrl: process.env.VUE_APP_BASE_API,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 分页器每页显示
      page_size: [5, 10, 15, 20, 25, 30, 100],
      // 当前页数
      pageNumArch: 1,
      // 偏移量
      pageSizeArch: 5,
      // 当前页数
      pageNumFile: 1,
      // 偏移量
      pageSizeFile: 5,
      // 高级查询值
      heightValue: null,
      // 高级查询参数
      heightParam: null,
      // 判断是否超级管理员
      isAdmin: false,
      // 判断是否开启档号自动生成，0：档号自动生成  1：手动录入
      is_docNum: null,
      // 案卷表名称
      tbName_arch: this.subData.tableList[0].tbName,
      // 卷内表名称
      tbName_file: this.subData.tableList[1].tbName,
      // 表档案分类ID，用于查询档案数据
      typeId: this.subData.typeId,
      // 用于带入初始化案卷全宗号值
      fullAnces: null,
      // 是否基础字段，isCustom: 0：动态字段 1：案卷表基础字段，2：卷内表基础字段，3：独立表基础字段
      isCustomArch: "1",
      isCustomFile: "2",
      // 是否可见。0可见，1隐藏
      isView: "0",
      // 是否禁用。0正常，1禁用
      status: "0",
      // 判断提交类型。0：修改， 1：新增
      subType: null,

      /********************************************案卷级**********************************/
      // 动态字段，显示
      tableHeaderViewArch: [],
      // 动态字段，新增，修改
      tableHeaderArch: [],
      // 选中数组
      ids: [],
      // 总条数
      totalArch: 0,
      // 案卷管理表格数据
      archivesList: [],
      // 背脊打印数据
      archivesListBack: [],
      // 弹出层标题
      titleArch: "",
      // 是否显示弹出层
      archOpen: false,
      // 查询参数
      queryParamsArch: {
        pageNum: this.pageNumArch,
        pageSize: this.pageSizeArch
      },
      // 高级查询参数
      heightArch: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: ""
      },
      // 归档选项
      heightOptionFinish: [
        {
          label: "未申请",
          value: "0"
        },
        {
          label: "申请中",
          value: "1"
        },
        {
          label: "审核通过",
          value: "2"
        },
        {
          label: "审核拒绝",
          value: "3"
        }
      ],
      // 表单参数
      formArch: {
        acFullAnces: this.fullAnces
      },
      // 表单校验
 /*      rulesArch: {
        typeId: [
          { required: true, message: "档案分类不能为空", trigger: "change" }
        ],
        acFullAnces: [
          { required: true, message: "全宗号不能为空", trigger: "blur" }
        ],
        acDirNum: [
          { required: true, message: "目录号不能为空", trigger: "blur" }
        ],
        acArchNum: [
          { required: true, message: "案卷号不能为空", trigger: "blur" }
        ],
        acFileTitle: [
          { required: true, message: "案卷题名不能为空", trigger: "blur" }
        ],
        acStoreTime: [
          { required: true, message: "保存期限不能为空", trigger: "blur" }
        ],
        acDocNum: [
          { required: true, message: "全宗号不能为空", trigger: "blur" }
        ],
        acYear: [
          { required: true, message: "年度不能为空", trigger: "blur" }
        ],
        acCategoryNo: [
          { required: true, message: "分类号不能为空", trigger: "blur" }
        ]
      }, */
      // 案卷导入参数
      uploadArch: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/RecordManage/import",
        // 上传参数
        data: {}
      },
      /******************文件级********************/
      // 动态字段，显示
      tableHeaderViewFile: [],
      // 动态字段，新增，修改
      tableHeaderFile: [],
      // 是否归档
      archStatus: null,
      // 普通上传的档案号参数
      fileNum: null,
      // 批量上传的档案号参数
      fileNumMult: null,
      // 批量上传文件路径
      filePath: null,
      // 批量上传案卷id
      archId: null,
      // 总条数
      totalFile: 0,
      // 文件管理表格数据
      fileList: [],
      // 新增文件，案卷题名下拉
      archivesListOption: [],
      // 弹出层标题
      titleFile: "",
      // 是否显示文件新增修改弹出层
      openFile: false,
      // 是否显示批量上传弹出层
      openMult: false,
      // 查询参数
      queryParamsFile: {
        pageNum: this.pageNumFile,
        pageSize: this.pageSizeFile
      },
      // 高级查询参数
      heightFile: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: ""
      },
      // 表单参数
      formFile: {},
      // 用于初始化新增文件
      archId: null, // 案卷ID
      fullAncesFile: null, // 全宗号
      archNumFile: null, // 案卷号
      storeTimeFile: null, // 保存期限
      yearFile: null, // 年度
      categoryNoFile: null, // 分类号
      secretLevelFile: null, // 密级
      // 表单校验
 /*      rulesFile: {
        archId: [
          { required: true, message: "案卷题名不能为空", trigger: "change" }
        ],
        fullAnces: [
          { required: true, message: "全宗号不能为空", trigger: "blur" }
        ],
        dirNum: [
          { required: true, message: "目录号不能为空", trigger: "blur" }
        ],
        archNum: [
          { required: true, message: "案卷号不能为空", trigger: "blur" }
        ],
        sequeNum: [
          { required: true, message: "顺序号不能为空", trigger: "blur" }
        ],
        fileTitle: [
          { required: true, message: "文件题名不能为空", trigger: "blur" }
        ],
        storeTime: [
          { required: true, message: "保存期限不能为空", trigger: "blur" }
        ],
        docNum: [
          { required: true, message: "档号不能为空", trigger: "blur" }
        ],
        year: [
          { required: true, message: "年度不能为空", trigger: "blur" }
        ],
        categoryNo: [
          { required: true, message: "分类号不能为空", trigger: "blur" }
        ]
      }, */
      // 文件导入参数
      uploadFile: {
        // 是否显示弹出层
        open: false,
        // 弹出层标题
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/system/RecordManage/import",
        // 上传参数
        data: {}
      }
    };
  },
  /**************************js部分*************************/
  created() {
    // 初始化文件列表
    this.initListArch(this.typeId);
    // 获取表头
    this.getTbHeaderArch();
    this.getTbHeaderViewArch();
    this.getTbHeaderFile();
    this.getTbHeaderViewFile();
    // 判断是否超级管理员或管理员
    getInfo().then(res => {
        for (let i in res.roles) {
            if (res.roles[i] === "admin" || res.roles[i] === "record_admin") {
                this.isAdmin = true;
            }
        }
        //获取部门全宗号
        getDept(res.user.deptId).then(res => {
          this.fullAnces = res.data.fullAnces;
        });
    });
    // 判断是否开启档号自动生成
    this.getConfigKey("is_docNum").then(response => {
      this.is_docNum = response.msg;
    });
  },
  // 监听树形菜单分类id值变化
  watch: {
    subData: {
      handler(newData) {
        this.tbName_arch = newData.tableList[0].tbName;
        this.tbName_file = newData.tableList[1].tbName;
        this.typeId = newData.typeId;
        this.pageNumArch = 1; //从第一页开始查询
        this.pageNumFile = 1; //从第一页开始查询
        this.initListArch();
        this.getTbHeaderArch();
        this.getTbHeaderViewArch();
        this.getTbHeaderFile();
        this.getTbHeaderViewFile();
      },
      deep: true
    }
  },
  methods: {
    // 字段分组，4个属性一行
    propGroup(items, i) {
      let arryy = [];
      let oldarr = items;
      for (let y = i; y < oldarr.length; y++) {
        if (arryy.length < 4) {
          arryy.push(items[y]);
        } else {
          break;
        }
      }
      return arryy;
    },
    // 格式化时间
    dateFormat(row, column, cellValue, index) {
      const daterc = row[column.property];
      if (daterc != null) {
        const timeFormat = this.dayjs(daterc).format("YYYY-MM-DD HH:mm:ss");
        return timeFormat;
      }
    },
    /*******************************案卷级*************************/
    // 改变size触发
    handleSizeChangeArch(val) {
      this.pageSizeArch = val;
      this.getListArch();
    },
    // 前往触发
    handleCurrentChangeArch(val) {
      this.pageNumArch = val;
      this.getListArch();
    },

    // 初始文件列表
    initListArch(typeId) {
      // 重置文件列表
      this.fileList = null;
      this.totalFile = 0;
      // 查询案卷列表
      this.queryParamsArch.pageNum = this.pageNumArch;
      this.queryParamsArch.pageSize = this.pageSizeArch;
      this.queryParamsArch.typeId = this.typeId;
      this.queryParamsArch.tbName = this.tbName_arch;
      listFileA(this.queryParamsArch).then(response => {
        this.archivesList = response.data.list;
        this.totalArch = response.data.total;
        this.resetQueryArch(); // 重置查询参数
      });
    },
    /** 单选案卷信息，获取文件列表 */
    handleClickArch(val) {
      if (val != null) {
        // 初始化新增文件基础字段值，用于新增文件
        (this.archId = val.id), // 案卷ID
          (this.fullAncesFile = val.acFullAnces), // 全宗号
          (this.archNumFile = val.acArchNum), // 案卷号
          (this.storeTimeFile = val.acStoreTime), // 保存期限
          (this.yearFile = val.acYear), // 年度
          (this.categoryNoFile = val.acCategoryNo), // 分类号
          (this.secretLevelFile = val.acSecretLevel); // 密级
        // 查询单选数据
        this.pageNumFile = 1; // 第一页开始查询
        this.archId = val.id; // 查询文件信息用的案卷id
        this.fileNum = val.docNum; // 给文件上传初始化档案号，往后端上传作为文件路径
        this.archStatus = val.archStatus; // 显示隐藏修改删除按钮，判断是否归档
        this.queryParamsFile.pageNum = this.pageNumFile;
        this.queryParamsFile.pageSize = this.pageSizeFile;
        this.queryParamsFile.archId = this.archId;
        this.queryParamsFile.tbName = this.tbName_file;
        listFileA(this.queryParamsFile).then(response => {
          this.fileList = response.data.list;
          this.totalFile = response.data.total;
          this.resetQueryFile();
        });
      }
    },
    // 获取展示表头,
    getTbHeaderViewArch() {
      listProp({
        tableId: this.subData.tableList[0].id,
        isCustom: this.isCustomArch,
        isView: this.isView,
        status: this.status
      }).then(response => {
        this.tableHeaderViewArch = response.rows;
      });
    },
    // 获取新增修改表头,
    getTbHeaderArch() {
      listProp({
        tableId: this.subData.tableList[0].id,
        status: this.status
      }).then(response => {
        this.tableHeaderArch = response.rows;
      });
    },
    /** 查询案卷管理列表 */
    getListArch() {
      // 重置文件列表
      this.fileList = null;
      this.totalFile = 0;
      // 查询案卷
      this.queryParamsArch.pageNum = this.pageNumArch;
      this.queryParamsArch.pageSize = this.pageSizeArch;
      this.queryParamsArch.typeId = this.typeId;
      this.queryParamsArch.tbName = this.tbName_arch;
      listFileA(this.queryParamsArch).then(response => {
        this.archivesList = response.data.list;
        this.totalArch = response.data.total;
        this.resetQueryArch(); // 重置查询参数
      });
    },
    // 取消按钮
    cancelArch() {
      this.archOpen = false;
      this.resetArch(); // 表达重置
    },
    // 表单重置
    resetArch() {
      this.formArch = {
        acFullAnces: this.fullAnces
      };
      this.resetForm("formArch");
    },
    /** 重置查询参数 */
    resetQueryArch() {
      this.resetQueryFile();
      this.queryParamsArch = {};
    },
    // 多选框选中数据
    handleSelectionChangeArch(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAddArch() {
      this.resetArch();
      this.archOpen = true;
      this.titleArch = "添加案卷管理";
      this.subType = 1;
    },
    /** 修改按钮操作 */
    handleUpdateArch(row) {
      this.resetArch();
      const id = row.id || this.ids;
      getFileA(id, { tbName: this.tbName_arch }).then(response => {
        this.formArch = response.data;
        this.archOpen = true;
        this.titleArch = "修改案卷管理";
        this.subType = 0;
      });
    },
    /** 案卷包导出按钮操作 */
    anjuanbaoExport(row) {
      this.queryParamsArch.tbName = this.tbName_file; // 用于查询文件
      this.queryParamsArch.tbType = this.subData.tableList[0].tbType; // 用于查询文件
      this.queryParamsArch.tableId = this.subData.tableList[0].id; // 用于导出表头
      this.queryParamsArch.isCustom = this.isCustomArch; //独立表基础字段
      this.queryParamsArch.status = this.status; //正常状态
      this.download(
        "system/RecordManage/anJuanBaoExport/" + row.id,
        {
          ...this.queryParamsArch
        },
        `案卷包_${new Date().getTime()}.zip`
      );
    },
    /** 提交按钮 */
    submitFormArch() {
      this.$refs["formArch"].validate(valid => {
        if (valid) {
          this.formArch.typeId = this.typeId;
          this.formArch.tbName = this.tbName_arch;
          if (this.subType == 0) {
            // subType: 0 修改
            updateFileA(this.formArch).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.subType = null; // 重置判断状态
              this.archOpen = false;
              this.getListArch();
            });
          } else if (this.subType == 1) {
            // subType: 1 新增
            this.formArch.tbType = "1"; //表类型。1：案卷管理表，2：卷内文件表，3：独立文件表
            addFileA(this.formArch).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.subType = null; // 重置判断状态
              this.archOpen = false;
              this.getListArch();
            });
          } else {
            this.$modal.msgError("请选择提交类型");
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDeleteArch(row) {
      let that = this;
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除案卷管理编号为"' + ids + '"的数据项？')
        .then(function() {
          return delFileA(ids, { tbName: that.tbName_arch });
        })
        .then(() => {
          this.getListArch();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 打印封皮 */
    handlePrintCover(row) {
      this.download(
        "/system/jasper/cover/",
        {
          ...row
        },
        `封皮_${new Date().getTime()}.pdf`,
        "pdf"
      );
    },
    /** 卷内备考表打印  */
    handlePrintBkTable(row) {
      console.log("卷内备考表打印=====>", row);
      const params = {
        pageCounts: row.pageCounts,
        createBy: row.createBy,
        createTime: row.createTime || " ",
        updateBy: row.updateBy,
        updateTime: row.updateTime || " "
      };
      this.download(
        "/system/jasper/bkTable/",
        { ...params },
        `卷内备考表_${new Date().getTime()}.pdf`,
        "pdf"
      );
    },
    /** 验收清单打印  */
    handlePrintAcceptance(row) {
      const params = {
        enginName: row.rEngin.enginName,
        unitProjectName: row.rEngin.unitProjectName,
        handoverUnit: row.rEngin.handoverUnit,
        registNum: row.registNum
      };
      this.download(
        "/system/jasper/acceptance/",
        { ...params },
        `卷内备考表_${new Date().getTime()}.pdf`,
        "pdf"
      );
    },
    /** 高级查询按钮操作 */
    handleHeighArch() {
      this.heightArch.title = "案卷高级查询";
      this.heightArch.open = true;
    },
    /** 高级查询 */
    getHeightArch() {
      this.queryParamsArch[this.heightParam] = this.heightValue;
      this.pageNumArch = 1; // 第一页开始查询
      this.fileList = []; // 清空文件列表
      this.getListArch();
      this.heightValue = null;
      this.heightParam = null;
      this.heightArch.open = false;
    },
    /** 导出按钮操作 */
    handleExportArch() {
      this.queryParamsArch.typeId = this.typeId; // 用于查询数据，二级菜单id
      this.queryParamsArch.tbName = this.tbName_arch; // 用于查询数据
      this.queryParamsArch.tableId = this.subData.tableList[0].id; // 用于导出表头
      this.queryParamsArch.isCustom = this.isCustomArch; //独立表基础字段
      this.queryParamsArch.status = this.status; //正常状态
      this.download(
        "system/RecordManage/export",
        {
          ...this.queryParamsArch
        },
        `archives_${new Date().getTime()}.xlsx`
      );
    },
    /** 导入按钮操作 */
    handleImportArch() {
      this.uploadArch.title = "案卷导入";
      this.uploadArch.open = true;
      this.uploadArch.data = {
        tbName: this.tbName_arch,
        tableId: this.subData.tableList[0].id,
        isCustom: this.isCustomArch,
        tbType: "1"
      };
    },
    /** 下载模板操作 */
    importTemplateArch() {
      this.queryParamsArch.tableId = this.subData.tableList[0].id; // 用于导出表头
      this.queryParamsArch.isCustom = this.isCustomArch; //独立表基础字段
      this.queryParamsArch.status = this.status; //正常状态
      this.download(
        "system/RecordManage/importTemplate",
        {
          ...this.queryParamsArch
        },
        `archives_template_${new Date().getTime()}.xlsx`
      );
    },
    // 文件上传中处理
    handleFileUploadProgressArch(event, file, fileList) {
      this.uploadArch.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccessArch(response, file, fileList) {
      this.uploadArch.open = false;
      this.uploadArch.isUploading = false;
      this.$refs.uploadArch.clearFiles();
      this.$alert(
        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
          response.msg +
          "</div>",
        "导入结果",
        { dangerouslyUseHTMLString: true }
      );
      this.getListArch();
    },
    // 提交上传文件
    submitFileFormArch() {
      this.$refs.uploadArch.submit();
    },
    // 归档申请按钮
    handleApply() {
      let that = this;
      const ids = this.ids;
      this.$modal
        .confirm('是否确认申请案卷归档编号为"' + ids + '"的数据项？')
        .then(function() {
          return updateApply(ids, { tbName: that.tbName_arch, tbType: "1" });
        })
        .then(() => {
          this.getListArch();
          this.$modal.msgSuccess("申请成功");
        })
        .catch(() => {});
    },
    // 归档审批通过按钮
    handleApprove() {
      let that = this;
      const ids = this.ids;
      this.$modal
        .confirm('是否确认审批通过案卷归档编号为"' + ids + '"的数据项？')
        .then(function() {
          return updateApprove(ids, { tbName: that.tbName_arch, tbType: "1" });
        })
        .then(() => {
          this.getListArch();
          this.$modal.msgSuccess("审批成功");
        })
        .catch(() => {});
    },
    // 归档审批拒绝按钮
    handleReject() {
      let that = this;
      const ids = this.ids;
      this.$modal
        .confirm('是否确认审批拒绝案卷归档编号为"' + ids + '"的数据项？')
        .then(function() {
          return updateReject(ids, { tbName: that.tbName_arch, tbType: "1" });
        })
        .then(() => {
          this.getListArch();
          this.$modal.msgSuccess("审批成功");
        })
        .catch(() => {});
    },
    // 更多操作触发
    handleCommandArch(command, row) {
      switch (command) {
        case "handleDeleteArch":
          this.handleDeleteArch(row);
          break;
        case "handlePrintCover":
          this.handlePrintCover(row);
          break;
        case "handlePrintBkTable":
          this.handlePrintBkTable(row);
          break;
        case "handlePrintAcceptance":
          this.handlePrintAcceptance(row);
          break;
        case "anjuanbaoExport":
          this.anjuanbaoExport(row);
          break;
        case "handleMultipleFile":
          this.handleMultipleFile(row);
          break;
        default:
          break;
      }
    },

    handlePrintBack() {
      let dataList = [];
      this.archivesListBack.forEach(element => {
        let temp = {};
        temp.archiveFileNum = element.archiveFileNum;
        temp.caseFileTitle = element.caseFileTitle;
        temp.registNum = element.registNum;
        dataList.push(temp);
      });
      this.download(
        "/system/jasper/back/",
        {
          dataList: dataList
        },
        `背脊_${new Date().getTime()}.pdf`,
        "pdf",
        "application/json"
      );
    },
    /*******************************文件级*************************/
    // 改变size触发
    handleSizeChangeFile(val) {
      this.pageSizeFile = val;
      this.getListFile();
    },
    // 前往触发
    handleCurrentChangeFile(val) {
      this.pageNumFile = val;
      this.getListFile();
    },

    /** 卷内文件目录打印 */
    handlePrintMenu() {
      let dataList = [];
      this.fileList.forEach((element, index) => {
        let temp = {};
        temp.sequenceNum = index + 1;
        temp.fileNo = element.fileNo;
        temp.docTitle = element.docTitle;
        temp.filePath = element.filePath;
        temp.pageCounts = element.pageCounts;
        temp.pageNo = element.pageNo;
        temp.remark = element.remark;
        dataList.push(temp);
      });
      this.download(
        "/system/jasper/menu/",
        {
          id: 0, //TODO
          dataList: dataList
        },
        `卷内文件目录_${new Date().getTime()}.pdf`,
        "pdf",
        "application/json"
      );
    },
    // 文件路径处理
    getFilePath(filePaths) {
      var arrayPath = filePaths.split(",");
      for (let i in arrayPath) {
        arrayPath[i] = this.baseUrl + arrayPath[i];
      }
      return arrayPath;
    },
    // 获取文件名称
    getFileName(name) {
      if (name.lastIndexOf("/") > -1) {
        return name.slice(name.lastIndexOf("/") + 1).toLowerCase();
      } else {
        return "";
      }
    },
    // 打印图片
    printImage(imgPaths) {
      var arrayPath = imgPaths.split(",");
      for (let i in arrayPath) {
        arrayPath[i] = this.baseUrl + arrayPath[i];
      }
      print({
        printable: arrayPath,
        type: "image",
        imageStyle: "width:100%;margin-bottom:20px;"
      });
    },
    // 获取展示表头,
    getTbHeaderViewFile() {
      listProp({
        tableId: this.subData.tableList[1].id,
        isCustom: this.isCustomFile,
        isView: this.isView,
        status: this.status
      }).then(response => {
        this.tableHeaderViewFile = response.rows;
      });
    },
    // 获取新增修改表头,
    getTbHeaderFile() {
      listProp({
        tableId: this.subData.tableList[1].id,
        status: this.status
      }).then(response => {
        this.tableHeaderFile = response.rows;
      });
    },
    /** 查询文件管理列表 */
    getListFile() {
      this.queryParamsFile.pageNum = this.pageNumFile;
      this.queryParamsFile.pageSize = this.pageSizeFile;
      this.queryParamsFile.archId = this.archId;
      this.queryParamsFile.tbName = this.tbName_file;
      listFileA(this.queryParamsFile).then(response => {
        this.fileList = response.data.list;
        this.totalFile = response.data.total;
        this.resetQueryFile(); // 重置参数
      });
    },
    // 取消按钮
    cancelFile() {
      this.openMult = false; // 关闭批量上传弹窗
      this.openFile = false; // 关闭新增修改弹窗
      this.resetFile();
    },
    // 表单重置
    resetFile() {
      this.formFile = {};
      this.resetForm("formFile");
    },
    /** 重置按钮操作 */
    resetQueryFile() {
      this.queryParamsFile = {};
    },
    /** 多选框选中数据 */

    handleSelectionChangeFile(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAddFile() {
      this.resetFile();
      // 用于初始化新增文件
      this.formFile = { 
        archId : this.archId, // 案卷ID
        fullAnces : this.fullAncesFile, // 全宗号
        archNum : this.archNumFile, // 案卷号
        storeTime : this.storeTimeFile, // 保存期限
        year : this.yearFile, // 年度
        categoryNo : this.categoryNoFile, // 分类号
        secretLevel : this.secretLevelFile  // 密级
      };
      // 获取案卷题名下拉菜单，用于新增文件
      this.queryParamsArch.id = this.archId;
      this.queryParamsArch.tbName = this.tbName_arch;
      this.queryParamsArch.pageNum = 1;
      this.queryParamsArch.pageSize = 100;
      listFileA(this.queryParamsArch).then(response => {
        this.archivesListOption = response.data.list; // 下拉菜单
        this.resetQueryArch(); // 重置参数
      });
      this.openFile = true;
      this.titleFile = "添加文件管理";
      this.subType = 1;
    },
    /**新增文件远程搜索框 */
    remoteMethodArch(query) {
      if (query !== "" && query != null) {
        this.queryParamsArch.pageNum = 1;
        this.queryParamsArch.pageSize = 100;
        this.queryParamsArch.acFileTitle = query;
        this.queryParamsArch.typeId = this.typeId;
        this.queryParamsArch.tbName = this.tbName_arch;
        listFileA(this.queryParamsArch).then(response => {
          this.archivesListOption = response.data.list;
          this.resetQueryArch(); // 重置参数
        });
      }
    },
    /** 修改按钮操作 */
    handleUpdateFile(row) {
      this.resetFile();
      const id = row.id || this.ids;
      getFileA(id, { tbName: this.tbName_file }).then(response => {
        this.formFile = response.data;
        this.openFile = true;
        this.titleFile = "修改文件管理";
        this.subType = 0;
        // 获取案卷题名下拉菜单
        this.queryParamsArch.id = response.data.archId;
        this.queryParamsArch.tbName = this.tbName_arch;
        this.queryParamsArch.pageNum = 1;
        this.queryParamsArch.pageSize = 100;
        listFileA(this.queryParamsArch).then(response => {
          this.archivesListOption = response.data.list; // 下拉菜单
          this.resetQueryArch(); // 重置参数
        });
      });
    },
    /** 提交按钮 */
    submitFormFile() {
      this.$refs["formFile"].validate(valid => {
        if (valid) {
          this.formFile.tbName = this.tbName_file;
          if (this.subType == 0) {
            // subType: 0 修改
            updateFileA(this.formFile).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.subType = null; // 重置判断状态
              this.openFile = false;
              this.getListFile();
            });
          } else if (this.subType == 1) {
            // subType: 1 新增
            this.formFile.tbType = "2"; //表类型。1：案卷管理表，2：卷内文件表，3：独立文件表
            addFileA(this.formFile).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.subType = null; // 重置判断状态
              this.openFile = false;
              this.getListFile();
            });
          } else {
            this.$modal.msgError("请选择提交类型");
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDeleteFile(row) {
      let that = this;
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除文件管理编号为"' + ids + '"的数据项？')
        .then(function() {
          return delFileA(ids, { tbName: that.tbName_file });
        })
        .then(() => {
          this.getListFile();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 批量文件上传按钮 */
    handleMultipleFile(row) {
      this.fileNumMult = row.docNum; // 批量上传档号参数，作为路径参数
      this.archId = row.id; // 批量上传案卷id
      this.openMult = true;
      this.titleFile = "批量文件上传";
    },
    /** 批量上传提交 */
    submitFormFileMult() {
      // filePath文件路径 archId案卷id。注：批量上传以案卷为单位，通过archId控制
      multFile({
        filePath: this.filePath,
        tbName: this.tbName_file,
        archId: this.archId,
        tbType: "2"
      }).then(response => {
        this.$alert(
          "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
            response.msg +
            "</div>",
          "挂载结果",
          { dangerouslyUseHTMLString: true }
        );
        this.openMult = false; // 关闭弹窗
        this.getListFile();
        this.filePath = null;
        this.archId = null;
      });
    },
    /** 高级查询按钮操作 */
    handleHeighFile() {
      this.heightFile.title = "文件高级查询";
      this.heightFile.open = true;
    },
    /** 高级查询 */
    getHeightFile() {
      this.queryParamsFile[this.heightParam] = this.heightValue;
      this.pageNumFile = 1; //第一页开始查询
      this.getListFile();
      this.heightValue = null;
      this.heightParam = null;
      this.heightFile.open = false;
    },
    /** 导出按钮操作 */
    handleExportFile() {
      this.queryParamsFile.archId = this.archId; // 用于查询数据
      this.queryParamsFile.tbName = this.tbName_file; // 用于查询数据
      this.queryParamsFile.tableId = this.subData.tableList[1].id; // 用于导出表头
      this.queryParamsFile.isCustom = this.isCustomFile; //独立表基础字段
      this.queryParamsFile.status = this.status; //正常状态
      this.download(
        "system/RecordManage/export",
        {
          ...this.queryParamsFile
        },
        `file_${new Date().getTime()}.xlsx`
      );
    },
    /** 导入按钮操作 */
    handleImportFile() {
      this.uploadFile.title = "文件导入";
      this.uploadFile.open = true;
      this.uploadFile.data = {
        tbName: this.tbName_file,
        tableId: this.subData.tableList[1].id,
        isCustom: this.isCustomFile,
        tbType: "2"
      };
    },
    /** 下载模板操作 */
    importTemplateFile() {
      this.queryParamsFile.tableId = this.subData.tableList[1].id; // 用于导出表头
      this.queryParamsFile.isCustom = this.isCustomFile; //独立表基础字段
      this.queryParamsFile.status = this.status; //正常状态
      this.download(
        "system/RecordManage/importTemplate",
        {
          ...this.queryParamsFile
        },
        `file_template_${new Date().getTime()}.xlsx`
      );
    },
    // 文件上传中处理
    handleFileUploadProgressFile(event, file, fileList) {
      this.uploadFile.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccessFile(response, file, fileList) {
      this.uploadFile.open = false;
      this.uploadFile.isUploading = false;
      this.$refs.uploadFile.clearFiles();
      this.$alert(
        "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
          response.msg +
          "</div>",
        "导入结果",
        { dangerouslyUseHTMLString: true }
      );
      this.getListFile();
    },
    // 提交上传文件
    submitFileFormFile() {
      this.$refs.uploadFile.submit();
    },
    // 更多操作触发
    handleCommandFile(command, row) {
      switch (command) {
        case "handleDeleteFile":
          this.handleDeleteFile(row);
          break;
        default:
          break;
      }
    }
  }
};
</script>

<style scoped>
.point {
  cursor: pointer;
}
.el-upload-list__item {
  border: 1px solid #e4e7ed;
  line-height: 2;
  margin-bottom: 10px;
  position: relative;
}
.ele-upload-list__item-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: inherit;
}
.box {
  width: 210mm;
  height: 297mm;
  opacity: 0;
  font-family: "微软雅黑";
  font-size: 14pt;
  z-index: -99;
  position: absolute;
}
.w-20 {
  width: 25%;
}
</style>
